# coding:utf8
import findspark

findspark.init()
from pyspark.sql import SparkSession

if __name__ == '__main__':
    # 0. 构建执行环境入口对象SparkSession
    spark = SparkSession.builder. \
        appName("test"). \
        master("local[*]"). \
        config("spark.sql.shuffle.partitions", 2). \
    config("spark.sql.warehouse.dir", "hdfs://bigdata:9820/user/hive/warehouse"). \
        config("hive.metastore.uris", "thrift://bigdata:9083"). \
        enableHiveSupport(). \
        getOrCreate()
sc = spark.sparkContext

spark.sql("SELECT * FROM test").show()
# 这里的spark.sql.warehouse.dir配置的是/opt/module/spark-3.0.1/conf/hive-site.xml中的hive.metastore.warehouse.dir元数据的存储路径
